package controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pojo.User;
import service.UserService;
import service.UserServiceImpl;

@Controller
public class UserController {
	
	@Resource(name="userservice")
	private UserService us;
	
	@RequestMapping(value="/addUser",method=RequestMethod.POST)
	public String addUser(User u){
		u=us.addUser(u);
		System.out.println(u.getName());
		return "login";
	}
	
	
	@RequestMapping(value="/findUser",method=RequestMethod.GET)
	@ResponseBody
	public String findUser(User u){		
		User user=us.findUser(u);
		if (user!=null) {
			return "success";
		}
	
		return "login";
	}
	

}
